package com.example.hal.model;

import java.util.List;




import org.restlet.resource.ClientResource;

import android.util.Log;

public class ActiviteController {
 public final ClientResource cr = new ClientResource(
 EngineConfiguration.gae_path + "/rest/activite");

 public ActiviteController() {
 EngineConfiguration.getInstance();
 }

 public void create(Activite activite) throws Exception {
 final ActiviteControllerInterface uci = cr
 .wrap(ActiviteControllerInterface.class);

 try {
 uci.create(activite);
 Log.i("ActiviteController", "Creation success !");
 } catch (Exception e) {
 Log.i("ActiviteController", "Creation failed ! "+e.getMessage());
 throw e;
 }
 }

 public List<Activite> getAllActivites() throws Exception {
 final ActiviteControllerInterface uci = cr
 .wrap(ActiviteControllerInterface.class);
 Container content;
 try{

	 content = uci.getAllActivites();
	 Log.i("ActiviteController", "getAllActivites success !");
 }catch (Exception e) {
	 Log.i("ActiviteController", "getAllActivites failed ! "+e.getMessage());
	 throw e;
	 }
 return content.getActivite_list();
 }
}